#include <iostream>
#include <cstring>
# define N 10 //学生人数
using namespace std;

//结构体
typedef struct student{
    string name;//名字
    float chinese_grade;//语文成绩
    float math_grade;//数学成绩
    float english_grade;//英语成绩
}stu;

//每个学生的总分
void all(stu s[],float sum[],int len){
    int i = 0;
    while(i<len)
    {
        sum[i] = s[i].chinese_grade + s[i].math_grade + s[i].english_grade;
        i++;
    }
}

//每科平均成绩
void avg(float &ch,float &ma,float &en,stu s[],int len){
    int i = 0;
    while(i<len)
    {
        ch = ch + s[i].chinese_grade;
        ma = ma + s[i].math_grade;
        en = en + s[i].english_grade;
        i++;
    }
    ch = ch/len;
    ma = ma/len;
    en = en/len;
}

int main()
{
    stu s[N] = {{"Emma",90.0,100.0,100.0},{"Larissa",85.5,95.0,95.0},{"Edith",90.0,90.0,90.0},{"Sophia",95.0,94.0,99.0},
                 {"Joyce",84.5,98.5,90.0},{"Ashley",90.0,86.0,100.0},{"May",85.0,88.0,90.0},{"lvy",75.0,80.0,85.0},
                 {"Hailey",70.0,86.5,85.0},{"Amy",70.0,82.0,78.0}};
    float ch = 0, ma = 0 , en = 0, sum[N] = {0};
    all(s,sum,N);//每个学生总分
    avg(ch,ma,en,s,N);//各个学科平均分
    cout << "每个学生总分 :" <<endl;
    for (int i=0;i<N;i++)
        cout << s[i].name << " : " << sum[i]<<endl;
    cout << "各个学科平均分 :" <<endl;
    cout << "语文平均分 :" << ch <<endl;
    cout << "数学平均分 :" << ma <<endl;
    cout << "英语平均分 :" << en <<endl;
    int max = 0, min = 0;
    for (int j=1;j<N;j++)
    {
        if (sum[j]>sum[max])
            max = j;
        if (sum[j]<sum[min])
            min = j;
    }
    cout << "总分最高的学生 : " <<endl;
    cout << s[max].name << " : " << sum[max]<<endl;
    cout << "总分最低的学生 : " <<endl;
    cout << s[min].name << " : " << sum[min]<<endl;
    return 0;
} 